package adim;

import javax.microedition.lcdui.*;

public class ConfirmDialog
{
	public Command CMD_YES, CMD_BACK;

	public static int NO = 0;
	public static int YES = 1;

	private Form _f;
	private int _result = NO;
	private String _title, _msg;
	
	public ConfirmDialog(CommandListener cl)
	{
		CMD_YES = new Command("Ok", Command.OK, 0);
		CMD_BACK = new Command("Back", Command.BACK, 0);

		/*TODO: get from constructor*/
		_f = new Form("Confirmation");
		_f.addCommand(CMD_YES);
		_f.addCommand(CMD_BACK);
		_f.setCommandListener(cl);

	}

	public void setTitle(String t)
	{
		_f.setTitle(t);
	}

	public void setMessage(String s)
	{
		try {
			_f.delete(0);
		} catch (java.lang.IndexOutOfBoundsException ioobe) {
			//first time around. pass
		}
		_f.append(s);
	}

	public int getResult()
	{
		return _result;
	}

	public Displayable getDisplay()
	{
		//return _tb;
		return _f;
	}
}
